CentOS 您所在的位置:网站首页 centos samba配置 CentOS

CentOS

2023-05-13 01:13| 来源: 网络整理| 查看: 265

CentOS---samba(安装、配置、使用) 

简介

本文只是教你快速的搭建一个可以共享的Samba服务器,如果想深入学习可以看看鸟哥的私房菜服务器架设

安装 samba

这个套件主要包含了 SAMBA 的主要 daemon 档案 (smbd及nmbd)、SAMBA的文件档 (document)、以及其它与SAMBA相关的 logrotate设定文件及开机预设选项档案等

samba-common

这个套件则主要提供了SAMBA的主要设定档 (smb.conf) 、 smb.conf语法检验的测试程序testparm等等

samba-client

这个套件则提供了当Linux做为SAMBA Client端时,所需要的工具指令,例如挂载SAMBA档案格式的执行档smbmount等等。

可以用yum install packagename命令进行安装

配置(1)不用密码 修改配置文件 [root@localhost ~]# vi /etc/samba/smb.conf

将smb.conf文件中的

security = user

改为

security = share

在smb.conf文件的最后部分添加如下内容:

[share]

comment = tmp share

path = /share

writeable = yes

browseable = yes

guest ok = yes

创建共享目录并设置权限 [root@localhost ~]# mkdir /share/ [root@localhost ~]# chmod -R 01777 /share/ 防火墙配置

打开/etc/sysconfig/iptables文件,添加如下内容:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT

当然了你还可以使用文本界面配置防火墙system-config-firewall-tui不过这样你又少了一次熟悉写防火墙规则的机会了 呵呵

配置SELinux [root@localhost ~]# chcon -R -t public_content_rw_t /share/ [root@localhost ~]# chcon -R -t samba_share_t /share/ [root@localhost ~]# setsebool samba_export_all_rw on

如果是/home, 还要执行如下命令:

[root@localhost ~]# getsebool -a|grep samba samba_domain_controller --> off samba_enable_home_dirs --> off samba_export_all_ro --> off samba_export_all_rw --> on samba_share_nfs --> off use_samba_home_dirs --> off virt_use_samba --> off [root@localhost ~]# setsebool samba_enable_home_dirs 1 或 [root@localhost ~]# setsebool samba_enable_home_dirs on 设置samba服务器开机自启动 [root@localhost ~]# chkconfig --level 35 smb on [root@localhost ~]# chkconfig --level 35 nmb on

当然了也可以使用ntsysv来配置

配置(2)需要密码 首先修改

security = share

security = user

添加共享

[samba]

comment = Linux Samba share

path = /home/samba

public = yes

browseable = yes

writable = yes

guest ok = no

create mask = 0664

directory mask = 0755

添加用户和samba用户 [root@localhost ~]# useradd samba [root@localhost ~]# passwd samba [root@localhost ~]# smbpasswd -a samba 使用 重启服务: [root@localhost ~]# service smb restart 或 [root@localhost ~]# /etc/rc.d/init.d/smb restart 或 [root@localhost ~]# service nmb restart Linux访问samba共享的资源

打开“文件浏览器”,在地址栏输入:smb://ipaddr

Windows访问samba共享的资源

打开“我的电脑”,在地址栏输入: \\ipaddr

注意:

Windows访问samba的共享资源时,需要将smb.conf文件中下面语句取消注释

;netbios name = MYSERVER

如果一切设置正确,windows仍然无法访问samba的共享资源时,要考虑“计算机名”重名的问题(因为局域网的电脑是网络传系统,设置起初都一样)。

      本文转自rshare 51CTO博客,原文链接:http://blog.51cto.com/1364952/1956282,如需转载请自行联系原作者


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有